<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>通知</title>
    <link rel="stylesheet" type="text/css" href="../Styles/bootstrap.min.css" />
    <script type="text/javascript" src="../Scripts/jquery.min.js"></script>
    <script type="text/javascript" src="../Scripts/bootstrap.min.js"></script>
    <script type="text/javascript" src="../Scripts/vue.min.js"></script>
    <script type="text/javascript" src="../Styles/laypage/laypage.js"></script>
    <style>
     h2{
            padding-left: 7%;
        }
        .table_notice{
            width: 60%;
            margin-left:10%;
        }
    </style>
</head>
<body>
<div>
    <h2>通知列表</h2>
    <div class="table_notice">
        <table class="table table-bordered" id="table">
            <tr class="info">
                <th>名称</th>
                <th>发布人</th>
                <th>发布时间</th>
                <th>类型</th>
                <th>附件</th>
                <th>操作</th>
            </tr>
            <tr v-for="notice in noticeList" class="danger">
                <td>{{notice.ntheme}}</td>
                <td>{{notice.uname}}</td>
                <td>{{notice.publishTime}}</td>
                <template v-if="notice.depart_id!=20">
                  <td>部门</td>
                </template>               
                <template v-else>
                  <td>公司</td>
                </template> 
                
                <td ><a href="../downNoticeFile?fileName={{notice.nappendix}}">{{notice.nappendix}}</a></td>
              
                
                <td><button type="button" class="btn btn-default btn-xs look" v-bind:value=notice.nid>查看</button>
                </td>
            </tr>
        </table>
        <div id="layPage"></div>
    </div>

</div>
<script type="text/javascript">
    $(function () { 
    	var currentPage=1;
    	var notice = new Vue({
    		el:"#table",
    		data:{noticeList:""},
    		methods:{
    			getNoticeList:function(){
    				var _self = this;
    				$.ajax({
    		    		url:'../getNoticeList',
    		    		type:'post',
    		    		data:{'currentPage':currentPage},
    		    		dataType:'json',
    		    		success : function(result){
    		    			console.log(result);
    		    			_self.noticeList=result.noticeList;
    		    			
    		    			laypage({
        						cont:$("#layPage"),//分页内容所有显示的容器位置 
        						pages:result.total,//分页显示的总页数
        						 curr:currentPage,//当前页
        						 skin:'molv',//皮肤
        						 skip:true,//支持跳页的功能
        						 last:'尾页',
        						 groups:2, 
        						 jump:function(obj,first){//触发分页后的回调
        							 currentPage=obj.curr;
        							 if(!first){//一定要加此判断，否则初始时会无限刷新
        								 notice.getNoticeList();//获取当前页
        							 }
        						 }
        					});
    		    		}
    		    	});
    			}
    		}
    	})
    	notice.getNoticeList();
    	
    	//查看详情
        $("#table").on('click','.look', function(){
        	var nid=$(this).val();
        	var href ="../lookDetails?nid="+nid;
        	console.log(href);
        	window.location.href=href; 
        	/* $.ajax({
        		url:'../lookDetails',
        		type:'post',
        		data:{'nid':nid},
        		dataType:'json',
        		success:function(result){
        			
        		}
        	}) */
        })
    })
 </script>
</body>
</html>